---
name: "{{ item }}-network"
x-type: "hlfv1"
version: "1.0.0"
client:
  organization: "{{ item }}"
  cryptoconfig:
    path: "/fabric/keyfiles"
  connection:
    timeout:
      peer:
        endorser: 300
        eventHub: 300
        eventReg: 300
      orderer: 300
channels:
  firstchannel:
    orderers:
{% for orderer in allorderers %}
      - {{ orderer.name }}
{% endfor %}
    peers:
{% for peer in allpeers %}
      {{ peer.name }}:
        endorsingPeer: true
        chaincodeQuery: true
        eventSource: true
{% endfor %}
organizations:
{% for org in allorgs %}
  {{ org }}:
    mspid: "{{ org }}"
    cryptoPath: "{{ org }}/users/{username}@{{ org}}/msp"
    peers:
{% for peer in allpeers|selectattr('org', 'equalto', org)|list %}
      - {{ peer.name }}
{% endfor %}
    certificateAuthorities:
{% for ca in allcas|selectattr('org', 'equalto', org)|list %}
      - {{ ca.name }}
{% endfor %}
{% endfor %}
orderers:
{% for orderer in allorderers %}
  {{ orderer.name }}:
    url: "{{ orderer.name }}:7050"
    grpcOptions:
      ssl-target-name-override: "{{ orderer.name }}"
    tlsCACerts:
      path: "{{ '/fabric/keyfiles/'+orderer.org+'/orderers/'+orderer.name+'.'+orderer.org+'/tls/ca.crt' }}"
{% endfor %}
peers:
{% for peer in allpeers %}
  {{ peer.name }}:
    url: "{{ peer.name }}:7051"
    eventUrl: "{{ peer.name }}:7053"
    grpcOptions:
      ssl-target-name-override: "{{ peer.name }}"
    tlsCACerts:
      path: "{{ '/fabric/keyfiles/'+peer.org+'/tlsca/tlsca.'+peer.org+'-cert.pem' }}"
{% endfor %}
certificateAuthorities:
{% for ca in allcas|selectattr('org', 'equalto', item)|list %}
  {{ ca.name }}:
    url: "{{ tls|ternary('https','http') }}://{{ca.name}}:7054"
    caName: "{{ ca.name }}"
    httpOptions:
      verify: false
    tlsCACerts:
      path: "{{ '/fabric/keyfiles/'+ca.org+'/tlsca/tlsca.'+ca.org+'-cert.pem' }}"
{% endfor %}
